<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>从结果中提取所有行作为一个数组</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.pg-fetch-all-columns.html">pg_fetch_all_columns</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.pg-fetch-array.html">pg_fetch_array</a></div>
 <div class="up"><a href="ref.pgsql.html">PostgreSQL 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.pg-fetch-all" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">pg_fetch_all</h1>
    <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">pg_fetch_all</span> &mdash; <span class="dc-title">从结果中提取所有行作为一个数组</span></p>

   </div>
   <div class="refsect1 unknown-seealsp" id="refsect1-function.pg-fetch-all-unknown-seealsp">
    <h3 class="title">说明</h3>
    <div class="methodsynopsis dc-description">
     <span class="type">array</span> <span class="methodname"><strong>pg_fetch_all</strong></span>
      ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$result</code></span>
     )</div>

    <p class="para rdfs-comment">
     <span class="function"><strong>pg_fetch_all()</strong></span>
     从结果资源中返回一个包含有所有的行（元组/记录）的数组。如果没有更多行可供提取，则返回 <strong><code>FALSE</code></strong>。
    </p>
    <p class="para">
     <div class="example" id="example-2030">
      <p><strong>Example #1 <span class="function"><strong>pg_fetch_all()</strong></span> 例子</strong></p>
      <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$conn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_pconnect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=publisher"</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">$conn</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"An&nbsp;error&nbsp;occured.\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />}<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"SELECT&nbsp;*&nbsp;FROM&nbsp;authors"</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">$result</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"An&nbsp;error&nbsp;occured.\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />}<br /></span><span style="color: #0000BB">$arr&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_fetch_all</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$arr</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
      </div>

     </div>
    </p>
    <p class="para">
     参见 <span class="function"><a href="function.pg-fetch-row.html" class="function">pg_fetch_row()</a></span>，<span class="function"><a href="function.pg-fetch-array.html" class="function">pg_fetch_array()</a></span>，<span class="function"><a href="function.pg-fetch-object.html" class="function">pg_fetch_object()</a></span>
     和 <span class="function"><a href="function.pg-fetch-result.html" class="function">pg_fetch_result()</a></span>。
    </p>
   </div>

  </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.pg-fetch-all-columns.html">pg_fetch_all_columns</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.pg-fetch-array.html">pg_fetch_array</a></div>
 <div class="up"><a href="ref.pgsql.html">PostgreSQL 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
